﻿package plugin.unionChat.game
{
    import cmd.*;
    import com.core.*;
    import com.sh.game.consts.*;
    import com.sh.game.net.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.system.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.newteam.model.*;
    import plugin.social.consts.*;
    import uiresource.friend.*;
    import view.message.*;

    public class MenuGame extends MenuUI
    {
        private var unionArr:Array;
        private var _lastOver:Label;
        private var _menuData:Object;

        public function MenuGame()
        {
            this.unionArr = [{txt:"查看资料"}, {txt:"加为好友"}, {txt:"私聊"}, {txt:"复制名称"}, {txt:"邀请组队"}, {txt:"申请入队"}, {txt:"加黑名单"}];
            list_menu.mouseHandler = new Handler(this.menuHandler);
            return;
        }// end function

        public function setMenu(param1:Object) : void
        {
            this._menuData = param1;
            list_menu.array = this.unionArr;
            img_bg.height = 20 * this.unionArr.length;
            return;
        }// end function

        public function menuHandler(event:MouseEvent, param2:int) : void
        {
            var _loc_3:Box = null;
            var _loc_4:Label = null;
            event.stopPropagation();
            switch(event.type)
            {
                case MouseEvent.ROLL_OVER:
                {
                    _loc_3 = list_menu.getCell(param2);
                    _loc_4 = _loc_3.getChildByName("txt") as Label;
                    _loc_4.color = "0xfff7af";
                    this._lastOver = _loc_4;
                    break;
                }
                case MouseEvent.ROLL_OUT:
                {
                    if (this._lastOver)
                    {
                        this._lastOver.color = "0xb29a6c";
                    }
                    break;
                }
                case MouseEvent.CLICK:
                {
                    this.checkSelect(this.unionArr[param2].txt);
                    this.visible = false;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function checkSelect(param1:String) : void
        {
            var selectName:* = param1;
            switch(selectName)
            {
                case "查看资料":
                {
                    Server.instance.send(114, 7, this._menuData.rid, 0, ConnectType.SYSTEM);
                    break;
                }
                case "加黑名单":
                {
                    Alert2.show("您确定把" + this._menuData.name + "加入黑名单？（加入黑名单后无法收到对方的附近、世界、私人聊天）", "", ["确定", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    PluginManager.instance.sendToServer("social", CMDSocial.AddHei, _menuData.rid);
                }
                return;
            }// end function
            );
                    break;
                }
                case "删除":
                {
                    Alert2.show("您确定要将" + this._menuData.name + "从好友列表中删除？", "", ["确定", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    PluginManager.instance.sendToServer("social", CMDSocial.DeleteRela, [_menuData.rid]);
                }
                return;
            }// end function
            );
                    break;
                }
                case "好友置顶":
                {
                    PluginManager.instance.sendToServer("social", CMDSocial.UpIndex, {rid:this._menuData.rid, param:1});
                    break;
                }
                case "邀请组队":
                {
                    PluginManager.instance.sendToServer("team", CMDteam.TEAM_INVITE, this._menuData.rid);
                    break;
                }
                case "申请入队":
                {
                    PluginManager.instance.sendToServer("team", CMDteam.TEAM_APPLY, this._menuData.rid);
                    break;
                }
                case "行会邀请":
                {
                    PluginManager.instance.sendToServer("union", CMDUnion.Invite, this._menuData.rid);
                    break;
                }
                case "复制名称":
                {
                    System.setClipboard(this._menuData.name);
                    break;
                }
                case "私聊":
                {
                    if (this._menuData.online)
                    {
                        PluginManager.instance.openPlugin("simpleChat", UIGlobel.pointsDic["social"], this._menuData);
                    }
                    else
                    {
                        ModelProxy.change("movetips", "error", "玩家不在线，不能进行私聊！");
                    }
                    break;
                }
                case "加为好友":
                {
                    PluginManager.instance.sendToServer("social", CMDSocial.APPLYFOR, this._menuData.rid);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
